//
//  QDSicknessTypeView.m
//  simulateQuickDoctor
//
//  Created by locklight on 17/3/26.
//  Copyright © 2017年 PipiXia. All rights reserved.
//

#import "QDSicknessTypeView.h"

@interface QDSicknessTypeView ()

/**
 *  底部分割线view
 */
@property (strong, nonatomic) UIView *lineView;

/**
 *  疾病类型label
 */
@property (strong, nonatomic) UILabel *illnessTypeLabel;

/**
 *  选择疾病label
 */
@property (strong, nonatomic) UILabel *illnessChoiceLabel;

/**
 *  右箭头imgView
 */
@property (strong, nonatomic) UIImageView *arrowImageView;

@end

@implementation QDSicknessTypeView

- (instancetype)init {
    self = [super init];
    if (self) {
        [self setupUI];
    }
    return self;
}

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}

/**
 *  初始化UI
 */
- (void)setupUI {
    self.backgroundColor = [UIColor whiteColor];
    
    [self addSubview:self.lineView];
    [self addSubview:self.illnessTypeLabel];
    [self addSubview:self.illnesschoiceLabel];
    [self addSubview:self.arrowImageView];
    
    // 设置右箭头图片
    self.arrowImageView.image = [UIImage imageNamed:@"position-right"];
    
    // 自动布局子控件
    
    [self.illnessTypeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(10);
        make.top.equalTo(self).offset(10);
    }];
    
    [self.arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-10);
        make.centerY.equalTo(self.illnessTypeLabel);
        make.size.mas_equalTo(CGSizeMake(15, 15));
    }];
    
    [self.illnesschoiceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.arrowImageView.mas_left).offset(-5);
        make.centerY.equalTo(self.arrowImageView);
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self);
        make.left.equalTo(self.illnessTypeLabel);
        make.right.equalTo(self);
        make.height.mas_equalTo(1);
    }];
}

#pragma mark - Setter方法

/**
 *  设置View的类型
 */
- (void)setIllnessTypeString:(NSString *)illnessTypeString {
    _illnessTypeString = illnessTypeString;
    self.illnessTypeLabel.text = illnessTypeString;
}

/**
 *  设置疾病的类型
 */
- (void)setIllnessChoiceString:(NSString *)illnessChoiceString {
    _illnessChoiceString = illnessChoiceString;
    _illnessChoiceLabel.text = illnessChoiceString;
    
}

#pragma mark - 懒加载子控件

- (UIView *)lineView {
    if (!_lineView) {
        _lineView = [[UIView alloc] init];
        _lineView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    }
    return _lineView;
}

- (UILabel *)illnessTypeLabel {
    if (!_illnessTypeLabel) {
        _illnessTypeLabel = [[UILabel alloc] init];
        _illnessTypeLabel.numberOfLines = 0;
        _illnessTypeLabel.text = @"疾病类型";
    }
    return _illnessTypeLabel;
}

- (UILabel *)illnesschoiceLabel {
    if (!_illnessChoiceLabel) {
        _illnessChoiceLabel = [[UILabel alloc] init];
        _illnessChoiceLabel.text = @"请选择";
        _illnessChoiceString = _illnessChoiceLabel.text;
        _illnessChoiceLabel.font = [UIFont systemFontOfSize:13];
        _illnessChoiceLabel.textColor = [UIColor grayColor];
        _illnessChoiceLabel.textAlignment = NSTextAlignmentRight;
    }
    return _illnessChoiceLabel;
}

- (UIImageView *)arrowImageView {
    if (!_arrowImageView) {
        _arrowImageView = [[UIImageView alloc] init];
    }
    return _arrowImageView;
}

@end
